import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CertificateVO, CertificateForm, CertificateQuery } from '@/api/business/certificate/types';

/**
 * 查询证书列表
 * @param query
 * @returns {*}
 */

export const listCertificate = (query?: CertificateQuery): AxiosPromise<CertificateVO[]> => {
  return request({
    url: '/business/certificate/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询证书详细
 * @param certificateId
 */
export const getCertificate = (certificateId: string | number): AxiosPromise<CertificateVO> => {
  return request({
    url: '/business/certificate/' + certificateId,
    method: 'get'
  });
};

/**
 * 新增证书
 * @param data
 */
export const addCertificate = (data: CertificateForm) => {
  return request({
    url: '/business/certificate',
    method: 'post',
    data: data
  });
};

/**
 * 修改证书
 * @param data
 */
export const updateCertificate = (data: CertificateForm) => {
  return request({
    url: '/business/certificate',
    method: 'put',
    data: data
  });
};

/**
 * 删除证书
 * @param certificateId
 */
export const delCertificate = (certificateId: string | number | Array<string | number>) => {
  return request({
    url: '/business/certificate/' + certificateId,
    method: 'delete'
  });
};
